function accurateOut(delay) {
    const time = Date.now()
    return function() {
        const gap = Date.now() - time
        setTimeout(() => {
            console.log(1)
        },delay - gap)
    }
}
// accurateOut(1000)()
//? 递归执行
function accurateTimeoutMany(time,fn) {
    let date = Date.now()
    let timer = null
    let n = 0
    function task(...args) {
        //? 让date要变的
        date += time
        timer = setTimeout(() => {
            fn.apply(args)
            task(++n)
        },date - Date.now())
    }
    task(n)
    return () => clearTimeout(timer)
}
const end = accurateTimeoutMany(1000,console.log)
setTimeout(() => {
    end()
},4000)
